package com.learn.chain.second;

import java.util.ArrayList;
import java.util.List;

public class OkClient {

    // 创建一个集合来存储拦截器
    private ArrayList<Interceptor> interceptors = new ArrayList<>();

    public OkClient(Builder builder) {
        this.interceptors = builder.arrayList;
    }

    public List<Interceptor> interceptors() {
        return interceptors;
    }

    // 创建发起请求方法
    public RealCall newCall(Request request) {
        return new RealCall(this, request);
    }

    public static class Builder {

        private ArrayList<Interceptor> arrayList = new ArrayList<>();

        public Builder addInterceptor(Interceptor interceptor) {
            arrayList.add(interceptor);
            return this;
        }

        public OkClient build() {
            return new OkClient(this);
        }
    }
}
